package com.pkk.penguin.frame.know.java.interview.year2021.atguigu_20210226.dependency;

import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;

/**
 * 依赖A
 *
 * @author peikunkun
 * @version V1.0
 * @date 2021-03-11 17:33
 **/
@SpringBootTest
@ComponentScan(basePackages = "com.pkk.penguin.frame.know.java.interview.year2021.atguigu_20210226.dependency")
public class DependencyTest {


  @Test
  public void Administrator_18_20210311174232_() {
    System.out.println("欢迎使用单元测试方法【Administrator_18()_20210311174232】");
    System.out.println("此方法测试描述：【Spring循环依赖\n"
        + "1.Spring单例循环依赖解决的核心主要是 DefaultSingletonBeanRegistry的三级缓存的二,三级缓存\n"
        + "2.Spring的原形模式,不可以用二三级缓存解决循环依赖,因为每次获取都是新创建,也不会进行缓存】");



    System.out.println("循环依赖异常\n"
        + "Caused by: org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'dependencyA': Requested bean is currently in creation: Is there an unresolvable circular reference?");

    final AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext(
        DependencyTest.class);
    annotationConfigApplicationContext.getBean(DependencyA.class);
    annotationConfigApplicationContext.getBean(DependencyB.class);







  }
}
